#include<iostream>
using namespace std;

typedef struct DuLNode{
	int data;
	struct DuLNode *prior;
	struct DuLNode *next;
}DuLNode,*DuLinkList;
void ListCreate(DuLinkList &L){
	L=new DuLNode();
	L->prior=L;
	L->next=L;
}
DuLinkList GetElem(DuLinkList L,int i){
	DuLinkList p=L->next;
	int j=1;
	while(p!=L&&j<i){
		p=p->next;
		j++;
	}
	if(p==L&&j<i){
		return NULL;
	}else{
		return p;
	}
}
bool ListInsert(DuLinkList &L,int i,int e){
	DuLinkList p,s;
	if(!(p=GetElem(L,i))){
		return false;
	}
	s=new DuLNode();
	s->data=e;
	s->prior=p->prior;
	p->prior->next=s;
	s->next=p;
	p->prior=s;
	return true;
}
bool ListDelete(DuLinkList &L,int i){
	DuLinkList p;
	if(!(p=GetElem(L,i))){
		return false;
	}
	p->prior->next=p->next;
	p->next=p->prior;
	delete p;
	return true;
}
void show(DuLinkList L){
	DuLinkList p=L->next;
	while(L!=p){
		printf("%d ",p->data);
		p=p->next;
	}
	printf("\n");
}
int main(){
	int zhiling,i,e;
	DuLinkList L;
	ListCreate(L);
	while(~scanf("%d",&zhiling)){
		if(zhiling==0){
			show(L);
		}else if(zhiling==1){
			scanf("%d%d",&i,&e);
			ListInsert(L,i,e);
		}else if(zhiling==2){
			scanf("%d",&i);
			ListDelete(L,i);
		}
	}
	return 0;
} 
